<?php
class Admin extends CI_Controller {
	
	public function __construct() {
		parent::__construct ();
		$this->load->model ( 'operat_Mod', 'op' );
		$this->load->library ( 'session' );
	}
	
	public function index() {
		
		if ($this->session->userdata ( "admin" )) {
			
			$this->view->display ( "admin" );
		} else {
			if (isset ( $_POST ["username"] )) {
				
				$this->enter ( 'admin/index' );
			}
			$this->view->display ( "admin_enter" );
		
		}
	}
	
	public function enter($page = 'admin/index') {
		$data = $this->op->decide_enter ();
		$this->session->set_userdata ( 'admin', $data );
		redirect ( $page );
	
	}
	
	public function head() {
		$this->view->display ( "admin_head" );
	}
	
	public function left() {
		
		$this->view->display ( "admin_left" );
	
	}
	
	public function right() {
		$this->view->display ( "admin_right" );
	
	}
	
	public function outreturn($page = 'admin/index') {
		
		$this->session->unset_userdata ( 'admin' );
		redirect ( $page );
	
	}

}
